package com.gaozhibo.mapper;

import com.gaozhibo.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {

    @Select("select * from user where user_name = #{s} or user_email = #{s}")
    User getUserByNameOrEmail(String s) ;
    @Select("select * from user")
    List<User> listUser();

    @Insert("insert into user values" +
            "(null,#{userName},#{userPass},#{userNickname},#{userEmail}," +
            "#{userUrl},#{userAvatar},#{userLastLoginIp},#{userRegisterTime},#{userLastLoginTime},#{userStatus})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addUser(User user);

    @Select("select * from user where user_id = #{id}")
    User getUserById(Integer id);

    @Delete("delete from user where user_id = #{id}")
    void deleteUser(Integer id);
}
